package com.leyou.mapper;


import com.leyou.common.mapper.BaseMapper;
import com.leyou.domain.UserManage;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface UserManageMapper extends BaseMapper<UserManage> {

    @Select("select * from tb_user_manage")
    @Results({
            @Result(id = true,property = "id",column = "id"),
            @Result(property = "roles",column = "id",javaType = List.class,
                    many = @Many(select = "com.leyou.mapper.RoleMapper.findByUid")
            )
    })
    public List<UserManage> findAll();

    /**
     * 新增用户角色中间表
     * @param uid
     * @param rids
     * @return
     */
    int insertUserRoles(@Param("uid") Long uid, @Param("rids") List<Long> rids);

    /**
     * 删除用户角色中间表
     * @param uid
     * @return
     */
    void deleteUserRole(Long uid);

}
